/*
 * @Author: cgl
 * @Date: 2023-04-19 14:57:57
 * @LastEditors: cgl
 * @LastEditTime: 2023-08-31 17:30:27
 * @FilePath: \public-health-emergencies-fed:\新放射\新radiation-hygiene-fe\src\api\slides\task.js
 * @Description:
 *
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved.
 */
import request from '@/utils/request'
import axios from 'axios'
import store from "@/store";

// 任务列表
export function personalDosimeterList(params) {
  return request({
    url: '/task/personalDosimeter/list',
    method: 'get',
    params,
  })
}
// 查看任务详情
export function personalDosimeterDetail(id) {
  return request({
    url: '/task/personalDosimeter/' + id,
    method: 'get'
  })
}
// 修改
export function personalDosimeterEdit(data) {
  return request({
    url: `/task/personalDosimeter/edit`,
    method: "post",
    data,
  });
}
// 添加
export function personalDosimeterAdd(data) {
  return request({
    url: `/task/personalDosimeter/add`,
    method: "post",
    data,
  });
}
// 获取办理数据
export function getHandleData(data) {
  return request({
    url: '/task/personalDosimeter/getHandleData',
    method: 'post',
    data,
  })
}
// 办理
export function personalDosimeterHandle(data) {
  return request({
    url: '/task/personalDosimeter/handle',
    method: 'post',
    data,
  })
}
// 审核
export function personalDosimeterProcess(data) {
  return request({
    url: `/task/personalDosimeter/process`,
    method: "post",
    data,
  });
}
// 生成报告
export function generateReport(dosimeterId, isPdf,type='report') {
  let url = type == 'report' ? `/task/personalDosimeter/generateReport/${dosimeterId}/${isPdf}` : `/task/personalDosimeter/generateRecordReport/${dosimeterId}/${isPdf}`
  return request({
    url,
    method: "get",
    headers: {
			isLoading: true,
      repeatSubmit: true
		}
  });
}
// 上传报告
export function uploadReport(params) {
  return request({
    url: `/task/personalDosimeter/uploadReport`,
    method: "post",
		params
  });
}
// 根据公司id获取受检人员列表
export function getWorkingPersonnelByOrganizationId(params) {
  return request({
    url: '/task/personalDosimeter/getWorkingPersonnelByOrganizationId',
    method: 'get',
    params,
  })
}
// 删除
export function personalDosimeterRemove(id) {
  return request({
    url: `/task/personalDosimeter/remove/${id}`,
    method: "post",
    data,
  });
}
// 获取未办理人员列表
export function getUnHandleWorkPersonnelList(dosimeterId) {
  return request({
    url: `/task/personalDosimeter/getUnHandleWorkPersonnelList/${dosimeterId}`,
    method: "get",
  });
}
// 添加寄出快递单号
export function addSendTrackingNumber(data) {
  return request({
    url: `/task/personalDosimeter/addSendTrackingNumber`,
    method: "post",
    data,
  });
}

// 查询年剂量任务分页列表
export function annualDoseList(params) {
  return request({
    url: `/task/annualDose/list`,
    method: "get",
    params,
  });
}

// 撤销
export function withdrawTask(dosimeterId) {
  return request({
    url: `/task/personalDosimeter/withdrawTask?dosimeterId=${dosimeterId}`,
    method: "post",
  });
}

// 撤销
export function getTaskDosimeterNextInfo(params) {
  return request({
    url: `/task/personalDosimeter/getTaskDosimeterNextInfo`,
    method: "get",
    params
  });
}

// 查询是否可生成年剂量报告
export function getQueryCanGenAnnualDose(params) {
  return request({
    url: `/task/annualDose/queryCanGenAnnualDose`,
    method: "get",
    params
  });
}

// 删除外照射任务
export function removePersonalDosimeter(id) {
  return request({
    url: `/task/personalDosimeter/remove/${id}`,
    method: "post",
  });
}

// 外照射任务人员列表
export function getTaskPersonalDosimeterParticipantList(params) {
  return request({
    url: `/task/taskPersonalDosimeterParticipant/listing`,
    method: "get",
    params
  });
}

// 外照射任务人员添加
export function getTaskPersonalDosimeterParticipantAdd(data) {
  return request({
    url: `/task/taskPersonalDosimeterParticipant/add`,
    method: "post",
    data
  });
}

// 外照射任务人员删除
export function getTaskPersonalDosimeterParticipantDel(ids) {
  return request({
    url: `/task/taskPersonalDosimeterParticipant/remove/${ids}`,
    method: "DELETE",
    // data
  });
}

// 收样删除应检人员
export function removePersonalResult(datas) {
  const { taskPersonalDosimeterId, taskPersonalResultIds } = datas
  return request({
    url: `/task/personalDosimeter/removePerson/${taskPersonalDosimeterId}`,
    method: 'post',
    data: taskPersonalResultIds,
  })
}

// 是否打印报告
export function personalPrintReport(params) {
  return request({
    url: `/task/personalDosimeter/printReport`,
    method: 'get',
    params,
  })
}

// 本底绑定列表
export function getBindBackground(params) {
  return request({
    url: `/task/personalDosimeter/getBindBackground`,
    method: 'get',
    params,
  })
}
// 绑定本底
export function bindBackgroundData(data) {
  return request({
    url: `/task/personalDosimeter/bindBackground`,
    method: 'post',
    data,
  })
}

// 流转登记表
export function genCirculationRegister(dosimeterId) {
  // return request({
  //   url: `/task/personalDosimeter/genCirculationRegister?dosimeterId=${dosimeterId}`,
  //   method: "post",
  // });
  return new Promise((resolve, reject) => {
    axios({
      url: process.env.VUE_APP_BASE_API + `/task/personalDosimeter/genCirculationRegister?dosimeterId=${dosimeterId}`,
      timeout: 0,
      method: 'post',
      responseType: 'blob',
      headers: {
        "Authorization": 'Bearer ' + store.getters.token
      },
    }).then(res => {
      resolve(res)
    }).catch(() => {
      resolve(false);
    });
  });
}

// 告知书
export function genDosageNotification(dosimeterId) {
  return new Promise((resolve, reject) => {
    axios({
      url: process.env.VUE_APP_BASE_API + `/task/personalDosimeter/genDosageNotification?dosimeterId=${dosimeterId}`,
      timeout: 0,
      method: 'post',
      responseType: 'blob',
      headers: {
        "Authorization": 'Bearer ' + store.getters.token
      },
    }).then(res => {
      resolve(res)
    }).catch(() => {
      resolve(false);
    });
  });
}

// 查询单位列表
export function getWaitOrganizations(params) {
  return request({
    url: `/task/personalDosimeter/getWaitOrganizations`,
    method: 'get',
    params: params,
  })
}
// 查询人员列表
export function getWaitPersons(entrustOrganizationId) {
  return request({
    url: `/basic/entrust/workingPersonnel/getWorkingPersonnels/${entrustOrganizationId}`,
    method: 'get',
  })
}
// 创建任务
export function createTask(data) {
  return request({
    url: `/task/personalDosimeter/createTask`,
    method: 'post',
    data: data
  })
}

// 审核配置列表
export function auditConfigList(params) {
  return request({
    url: `/biz/taskReportCheckConfig/list`,
    method: "get",
    params
  });
}

// 新增审核配置
export function auditConfigAdd(data) {
  return request({
    url: `/biz/taskReportCheckConfig/add`,
    method: "post",
    data
  });
}

// 删除审核配置
export function auditConfigDel(ids) {
  return request({
    url: `/biz/taskReportCheckConfig/remove/${ids}`,
    method: "get",
    // data
  });
}
